import WithdrawTarget from "../bg-enums/withdrawTarget";
import UserStratification from "../bg-enums/userStratification";
import StoreEndorseApplyField from "../bg-enums/storeEndorseApplyField";
import AuditResult from "../bg-enums/auditResult";

/****************************************************************************************/
/*                                   store                                              */
/****************************************************************************************/

export interface Store {
  storeId: string;
  name: string;
  brandId: string;
  intro?: string;
  pic?: string;
  homepageBg?: string;
  tel?: string;
  opened?: number;
  distributorId: string;
}

export interface StoreWithStat extends Store {
  // store_stat
  fansCount: number;
  publishActivityCount: number;
  spokesmanCount: number;
  endorseRequestToAuditCount: number;
  orderCount: number;
  saleAmount: number;
  refundAmount: number;
  distributeAmount: number;
  orderBonus: number;
  refundOrderBonus: number;
}

export interface StoreWithStatAndAccount extends StoreWithStat {
  // store_account
  availableAmount: number;
  pendingAmount: number;
  withdrawingAmount: number;
  withdrawedAmount: number;
}

export interface StoreWithStatAndEndorsement extends StoreWithStat {
  // store_endorsement
  isEndorsementEntranceDisplay: boolean;
  endorseSpokesmanId: string;
}

export interface OpenDistributeStoreParams {
  name: string;
  brandId: string;
  intro: string;
  pic: string;
  distributorId: string;
  userId: string;
}

export interface UpdatetoreInfoParams {
  storeId: string;
  name?: string;
  intro?: string;
  pic?: string;
  homepageBg?: string;
  tel?: string;
}

/****************************************************************************************/
/*                                   store_account_withdraw_applyment                   */
/****************************************************************************************/

export interface StoreAccountWithdrawApplyment {
  storeAccountWithdrawApplymentId: string;
  storeId: string;
  target: WithdrawTarget;
  applied: number;
  amount: number;
  remark: string;
  applyState: string;
}

export interface CreateStoreWithdrawApplymentParams {
  storeId: string;
  target: WithdrawTarget;
  amount: number;
  realName: string;
  idCardNo: string;
  remark: string;
}

/****************************************************************************************/
/*                                   store_account_log                                  */
/****************************************************************************************/
export interface AggrStoreAccountLogsToInOutRet {
  income: number;
  outlay: number;
}

/****************************************************************************************/
/*                                   store_endorsement                                  */
/****************************************************************************************/

export interface StoreEndorsement {
  storeId: string;
  isOpen: boolean;
  spokesmanTitle: string;
  userStratified: UserStratification;
  consumerLowerExpense?: number;
  needApplyInfo: boolean;
  applyInfoFields?: string[];
  isEntranceDisplay: boolean;
  isAutoApproved: boolean;
}

export interface UpsertStoreEndorsementParams {
  storeId: string;
  isOpen: boolean;
  spokesmanTitle: string;
  userStratified: UserStratification;
  consumerLowerExpense?: number;
  needApplyInfo: boolean;
  applyInfoFields?: StoreEndorseApplyField[];
  isEntranceDisplay: boolean;
  isAutoApproved: boolean;
}


/****************************************************************************************/
/*                                   store_fan                                          */
/****************************************************************************************/

export interface StoreFan {
  storeFanId: string;
  storeId: string;
  followerUserId: string;
  beFollowed?: number;
  aliasName: string;
  remark?: string;
}

export interface UpsertStoreFanParams {
  storeId: string;
  followerUserId: string;
  beFollowed: number;
  aliasName: string;
}

export interface UpdateStoreFanParams {
  storeFanId: string;
  aliasName: string;
  remark?: string;
}

export interface StoreFanWithUserAndUserStat extends StoreFan {
  // user
  followerUserNickName: string;
  followerUserPic: string;

  // user_stat
  fansCount?: number;
  followUserCount?: number;
  followBrandCount?: number;
  followStoreCount?: number;
  endorseBrandCount?: number;
  endorseStoreCount?: number;
  endorseActivityCount?: number;
  involveActivityCount?: number;
  orderCount?: number;
  viewCount?: number;
  payAmount?: number;
}

/****************************************************************************************/
/*                                   store_follow                                       */
/****************************************************************************************/

export interface StoreFollow {
  storeFollowId: string;
  userId: string;
  followedStoreId: string;
  followed?: number;
  remark?: string;
}

export interface UpsertStoreFollowParams {
  userId: string;
  followedStoreId: string;
  followed: number;
}

export interface UpdateStoreFollowParams {
  storeFollowId: string;
  aliasName: string;
  remark?: string;
}

export interface StoreFollowWithStoreAndStoreStat extends StoreFollow {
  // brand
  followedStoreName: string;
  followedStorePic: string;
  // brand_stat
  fansCount?: number;
  adminCount?: number;
  publishActivityCount?: number;
  spokesmanCount?: number;
  endorseRequestToAuditCount?: number;
}


/****************************************************************************************/
/*                                   store_endorse_request                              */
/****************************************************************************************/

export interface StoreEndorseRequest {
  storeEndorseRequestId: string;
  storeId: string;
  userId: string;
  requested: number;
  audited?: number;
  applyFields: string;
  auditResult: AuditResult;
}

export interface StoreEndorseRequestWithUserInfo extends StoreEndorseRequest {
  userPic: string;
}

export interface ApplyStoreEndorseRequestParams {
  storeId: string;
  userId: string;
  applyFields: string;
}

export interface AuditStoreEndorseRequestParams {
  storeEndorseRequestId: string;
  audited: number;
  auditResult: AuditResult;
}

/****************************************************************************************/
/*                                   store_spokesman                                    */
/****************************************************************************************/
export interface StoreSpokesman {
  storeSpokesmanId: string;
  userId: string;
  storeId: string;
  aliasName: string;
  became: number;
  remark?: string;
  endorseActivityCount: number;
  saleAmount: number;
}
export interface UpdateStoreSpokesmanParams {
  storeSpokesmanId: string;
  aliasName?: string;
  remark?: string;
}
export interface StoreSpokesmanCacheInfo {
  userId: string;
  storeId: string;
}

export interface StoreSpokesmanWithStore extends StoreSpokesman {
  // store
  storeName: string;
  storePic?: string;
  storeFansCount: number;
  storePublishActivityCount: number;
}

export interface StoreSpokesmanWithUser extends StoreSpokesman {
  // brand
  spokesmanUserNickName: string;
  spokesmanUserPic?: string;
  fansCount: number;
}